package com.agileboot.attendance.domain.supplier.dto;

import cn.hutool.core.bean.BeanUtil;
import com.agileboot.attendance.domain.supplier.db.AttSupplierEntity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * <p>
 * 供应商信息DTO
 * </p>
 *
 * @author agileboot
 * @since 2023-03-14
 */
@Data
@NoArgsConstructor
@ApiModel(value = "供应商信息")
public class SupplierDTO {

    @ApiModelProperty("供应商ID")
    @ExcelProperty("供应商ID")
    private Long supplierId;

    @ApiModelProperty("供应商名称")
    @ExcelProperty("供应商名称")
    private String supplierName;

    @ApiModelProperty("供应商编码")
    @ExcelProperty("供应商编码")
    private String supplierCode;

    @ApiModelProperty("联系人姓名")
    @ExcelProperty("联系人姓名")
    private String contactName;

    @ApiModelProperty("联系人电话")
    @ExcelProperty("联系人电话")
    private String contactPhone;

    @ApiModelProperty("联系人邮箱")
    @ExcelProperty("联系人邮箱")
    private String contactEmail;

    @ApiModelProperty("供应商地址")
    @ExcelProperty("供应商地址")
    private String address;

    @ApiModelProperty("状态（0正常 1停用）")
    private String status;

    @ApiModelProperty("状态名称")
    @ExcelProperty("状态")
    private String statusName;

    @ApiModelProperty("人员数量")
    @ExcelProperty("人员数量")
    private Long personnelCount;

    @ApiModelProperty("备注")
    @ExcelProperty("备注")
    private String remark;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ExcelProperty("创建时间")
    private Date createTime;

    /**
     * 构造函数，从实体类转换
     *
     * @param supplier 供应商实体类
     */
    public SupplierDTO(AttSupplierEntity supplier) {
        if (supplier != null) {
            BeanUtil.copyProperties(supplier, this);

            // 状态名称
            if ("0".equals(supplier.getStatus())) {
                this.statusName = "正常";
            } else if ("1".equals(supplier.getStatus())) {
                this.statusName = "停用";
            }
        }
    }
} 